updating oE which_bit

Flags

Routines

which_bit

include flags.e 
namespace flags 
public function which_bit(object theValue) 

tests if the supplied value has only a single bit on in its representation.

Parameters:
  1. theValue : an object to test.
Returns:

An integer, either 0 if it contains multiple bits, zero bits or is an invalid value, otherwise the bit number set. The right-most bit is position 1 and the leftmost bit is position 32.

Example 1:
? which_bit(2) --> 2 
? which_bit(0) --> 0 
? which_bit(3) --> 0 
? which_bit(4)          --> 3 
? which_bit(17)         --> 0 
? which_bit(1.7)        --> 0 
? which_bit(-2)         --> 0 
? which_bit("one")      --> 0 
? which_bit(0x80000000) --> 32 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu